<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>地址管理</title>  
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/base.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/detail.css" />
</head>
<body>
<div class="detail">
	<div class="manage">
		<volist name="list" id="vo">
		<div class="consignee <?=$vo['is_default']==1?'selected':''?>">
			<div class="consignee-msg">
				<div class="consignee-name"><span class="name"><?=$vo['name']?></span>
					<!--<b>家乡</b>--><span class="phone"><?=substr_replace($vo['mobile'],'****',3,4);?></span></div>
				<div class="addressnumber"><?=$vo['a_1_name'].$vo['a_2_name'].$vo['a_3_name'].$vo['content']?></div>
                <!--<div class="house">社区扶农店</div>-->
			</div>
			<div class="operation">
           		<span class="select-icon" data-id="{$vo.id}"><s></s></span>默认地址
				<span class="delete"  data-id="{$vo.id}">删除</span>
				<span class="bj" onClick="window.location='addrInfo/id/{$vo.id}'">编辑</span>
			</div>
		</div>
		</volist>
    </div>
    <div class="button">
		<!--<input type="button" value="新增地址"/>-->
		<input type="button" value="新增地址" onClick="window.location='addrInfo'"/>
	</div>
</div>
	<script src="__PUBLIC__/Wx/js/jquery.js" ></script>
	<script>

		// 修改默认地址
	    $(".select-icon").click(function(){
	        if($(this).parents(".consignee").hasClass("selected")){
	        }else{
                var this_a = $(this);
                var addr_id = $(this).attr('data-id');
                $.post('<?=U("MyAddress/changeDefault")?>',{addr_id:addr_id},function (data) {
                    if(data.status==1){
                       window.location.reload();
                    }else{
                        console.log(data);
                    }
                })

	        }
	    }); // end fun 修改默认

		// 删除地址
	    $(".delete").click(function(){
	        var this_a = $(this);
            var addr_id = $(this).attr('data-id');
            $.post('<?=U("MyAddress/delete")?>',{addr_id:addr_id},function (data) {
                if(data.status==1){
                    this_a.parents(".consignee").remove();
                }else{
                    console.log(data);
				}
            })
	    });// end fun 删除

	</script>

</body>
</html>